package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 老人用餐计划详情
 *
 * @author ytche
 * @date 2017年8月30日
 *
 */
@Entity
@Table(name = "tnb_customer_food_plan")
@JsonApiResource(type = "customerFoodPlan")
public class CustomerFoodPlan extends BaseEntity {
	private static final long serialVersionUID = 1L;

	private Integer diningDate;// 用餐日期

	private Dicttype diningTime;// 用餐时间

	private Customer customer;// 老人

    private Food  food;
	
	private Employee createEmployee;// 记录人

	private User createUser;// 创建人

	private Integer yearTab;// 年

	private Integer weekIndex;// 周序号

	private Integer weekTab;// 星期几

	private Dicttype planStatus;// 计划状态 pc发布

	private Dicttype confirmStatus;// 计划状态 移动端编辑确认状态 两个状态待定

	private CustomerDayFoodPlan dayPlan;
	
	private Integer createDateTime;
	
//	@Transient
//	@JsonApiToOne
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "day_plan_id")
	@JsonApiToOne
	public CustomerDayFoodPlan getDayPlan() {
		return dayPlan;
	}

	public void setDayPlan(CustomerDayFoodPlan dayPlan) {
		this.dayPlan = dayPlan;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "food_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Food getFood() {
		return food;
	}

	public void setFood(Food food) {
		this.food = food;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}


	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "confirm_status_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Dicttype getConfirmStatus() {
		return confirmStatus;
	}

	public void setConfirmStatus(Dicttype confirmStatus) {
		this.confirmStatus = confirmStatus;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "status_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Dicttype getPlanStatus() {
		return planStatus;
	}

	public void setPlanStatus(Dicttype planStatus) {
		this.planStatus = planStatus;
	}

	@Column(name = "year_tab")
	public Integer getYearTab() {
		return yearTab;
	}

	public void setYearTab(Integer yearTab) {
		this.yearTab = yearTab;
	}

	@Column(name = "week_tab")
	public Integer getWeekTab() {
		return weekTab;
	}

	public void setWeekTab(Integer weekTab) {
		this.weekTab = weekTab;
	}

	@Column(name = "week_index")
	public Integer getWeekIndex() {
		return weekIndex;
	}

	public void setWeekIndex(Integer weekIndex) {
		this.weekIndex = weekIndex;
	}

	@Column(name = "dining_date")
	public Integer getDiningDate() {
		return diningDate;
	}

	public void setDiningDate(Integer diningDate) {
		this.diningDate = diningDate;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "dinging_time_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Dicttype getDiningTime() {
		return diningTime;
	}

	public void setDiningTime(Dicttype diningTime) {
		this.diningTime = diningTime;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "customer_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

//	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
//	@JoinTable(name = "rel_food_plan", joinColumns = { @JoinColumn(name = "plan_id") }, inverseJoinColumns = {
//			@JoinColumn(name = "food_id") })
//	@Fetch(FetchMode.JOIN)
//	@JsonApiToMany
//	@JsonApiIncludeByDefault
//	public List<RelFoodPlan> getFoods() {
//		return foods;
//	}
//
//	public void setFoods(List<RelFoodPlan> foods) {
//		this.foods = foods;
//	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "create_employee_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Employee getCreateEmployee() {
		return createEmployee;
	}

	public void setCreateEmployee(Employee createEmployee) {
		this.createEmployee = createEmployee;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "create_user_id")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}
}
